﻿using UnityEngine;
using System;

namespace Shipwar.SDK
{
    public class SDK
    {

        public struct User
        {
            public string AppUID;
            public string APPToken;
            public int LoginType;
            public string Name;
        }

        public User currentUser;
        public Action onLoginFinishEvent;
        public void FireOnLogin()
        {
            if (onLoginFinishEvent != null)
            {
                onLoginFinishEvent();
            }
        }

        public Action<int> onLoginFailedEvent;
        protected void FireOnLoginFailed(int errCode)
        {
            if (onLoginFailedEvent != null)
            {
                onLoginFailedEvent(errCode);
            }
        }

        public Action<bool> onBindFinishEvent;
        protected void FireOnBindFinish(bool success)
        {
            if (onBindFinishEvent != null)
            {
                onBindFinishEvent(success);
            }
        }

        public virtual void StartLogin()
        {

        }

        public virtual void QuitLogin()
        {

        }

        public virtual void QueryCurrentUser()
        {

        }

        public virtual bool HasBindChannel(int loginType)
        {
            return false;
        }

        public virtual void BindLogin(int loginType)
        {

        }

        public virtual void OpenUrl(string url, string title)
        {
            Application.OpenURL(url);
        }

        public virtual void Report(string name, string token, params string[] parameters)
        {

        }

        public virtual void ShowFAQs(bool isEnterGame)
        {

        }

        public virtual string GetDeiviceID()
        {
            return "";
        }

        public virtual string GetAndroidID()
        {
            return "";
        }

        public virtual string GetGoogleAID()
        {
            return "";
        }

        public virtual string GetIDFA()
        {
            return "";
        }

        public virtual string GetDeviceModel()
        {
            return "";
        }

        public virtual string GetOSVersion()
        {
            return "";
        }

        public virtual string GetOSType()
        {
            return "pc";
        }

        public virtual string GetVersionName()
        {
            return "";
        }

        public virtual bool HasSDK()
        {
            return false;
        }

        public Action OpenShopCallback;
        public virtual void OpenShop()
        {

        }

        public virtual void BeginBuy(string sku)
        {

        }

        static SDK _instance;
        public static SDK GetInstance()
        {
            if(_instance == null)
            {
#if JJSDK
                _instance = new JJSDK();
#else
                _instance = new FakeSDK();
#endif
            }
            return _instance;
        }
    }
}

